package com.andy.springboot.ao;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * 分页条件
 * @author Andy.ye
 * @date 2018年3月23日 下午3:27:14
 */
public class PageCondition {

	public static int pageSize = 5;

	protected int page = 1;

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public Map<String, Object> getConditionMap() {
		Map<String, Object> conditionMap = Maps.newHashMap();
		conditionMap.put("pageSize", pageSize);
		return conditionMap;
	}

	public Map<String, Object> getPageConditionMap() {
		Map<String, Object> conditionMap = getConditionMap();
		if (page < 1) {
			page = 1;
		}
		conditionMap.put("pageSize", pageSize);
		conditionMap.put("startIndex", (page - 1) * pageSize);
		return conditionMap;
	}
}
